package com.yunfei.yunhetong.elecContOperLog.service.impl;
import java.util.*;
import com.yunfei.utils.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.yunfei.utils.BaseException;
import com.yunfei.utils.log.BaseLog;
import com.yunfei.utils.string.StringUtil;
import com.yunfei.utils.id.IdUtils;
import com.yunfei.mapper.aiiidb.ElecContOperLogMapper;
import com.yunfei.yunhetong.elecContOperLog.bo.*;
import com.yunfei.yunhetong.elecContOperLog.entity.*;
import com.yunfei.yunhetong.elecContOperLog.service.*;
import com.yunfei.yunhetong.elecContOperLog.service.impl.*;
   /**
    *@tablename eleccontoperlog
    *@author zhengyunfei
    *@createDate Tue Aug 27 10:30:57 CST 2019
    */ 
	@Service("eleccontoperlogService")
	public class ElecContOperLogServiceImpl implements ElecContOperLogService{
	@Autowired
	private ElecContOperLogMapper elecContOperLogMapper;
	/**
	*新增
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public String add(ElecContOperLogBo bo){
	String backInfo="保存成功";
	String id="";
		try{
			ElecContOperLogEntity entity=ElecContOperLogBo.boToEntity(bo);
			id= IdUtils.getId();
			elecContOperLogMapper.add(entity);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "add 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return id;
}
	/**
	*新增
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public String batchInsert(List list){
	String backInfo="保存成功";
	String id="";
		try{
			elecContOperLogMapper.add(list);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "batchInsert 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return id;
}
	/**
	*修改
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public String update(ElecContOperLogBo bo){
	String backInfo="修改成功";
		try{
			ElecContOperLogEntity entity=ElecContOperLogBo.boToEntity(bo);
			elecContOperLogMapper.update(entity);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "update更新失败", e);
			 throw new BaseException("更新！",e);
		}
		return backInfo;
}
	/**
	*删除
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public String delete(String id){
	String backInfo="删除成功";
		try{
			Map<String,Object> map=new HashMap<String, Object>();
			map.put("id",id.split(","));
			elecContOperLogMapper.delete(map);
		}catch(Exception e){
			 backInfo="保存失败";
			 BaseLog.e(this.getClass(), "add 添加失败", e);
			 throw new BaseException("添加！",e);
		}
		return backInfo;
}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public ElecContOperLogBo findById(String id){
		ElecContOperLogEntity entity=null;
		ElecContOperLogBo bo=null;
		try{
			entity=(ElecContOperLogEntity)elecContOperLogMapper.findById(id);
		if(!StringUtil.isNullOrEmpty(entity)){
				bo=ElecContOperLogBo.entityToBo(entity);
			}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
	}
		return bo;
	}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public ElecContOperLogBo findByMap(Map queryMap){
		ElecContOperLogEntity entity=null;
		ElecContOperLogBo bo=null;
		try{
			entity=(ElecContOperLogEntity)elecContOperLogMapper.get(queryMap);
			if(!StringUtil.isNullOrEmpty(entity)){
				bo=ElecContOperLogBo.entityToBo(entity);
			}
		}catch(Exception e){
			BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return bo;
}
	/**
	*根据Id查询
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public ElecContOperLogBo findByBo(ElecContOperLogBo param){
		ElecContOperLogEntity entity=null;
		ElecContOperLogBo bo=null;
		try{
			entity=(ElecContOperLogEntity)elecContOperLogMapper.findByBo(param);
			if(!StringUtil.isNullOrEmpty(entity)){
				bo=ElecContOperLogBo.entityToBo(entity);
			}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findById 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return bo;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public List<ElecContOperLogBo> findAllList(ElecContOperLogBo map){
		List<ElecContOperLogBo> boList=new ArrayList<ElecContOperLogBo>();
		List<ElecContOperLogEntity> entityList=new ArrayList<ElecContOperLogEntity>();
		try{
					entityList=elecContOperLogMapper.findAllList( map);
				for(int i=0;i<entityList.size();i++){
					ElecContOperLogEntity entity=entityList.get(i);
					ElecContOperLogBo bo=ElecContOperLogBo.entityToBo(entity);
					boList.add(bo);
				}
		}catch(Exception e){
				BaseLog.e(this.getClass(), "findAllList 查询失败", e);
				throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public List<ElecContOperLogBo> findAllList(Map<String,Object> map){
		List<ElecContOperLogBo> boList=new ArrayList<ElecContOperLogBo>();
		List<ElecContOperLogEntity> entityList=new ArrayList<ElecContOperLogEntity>();
		try{
				entityList=elecContOperLogMapper.findAllList( map);
			for(int i=0;i<entityList.size();i++){
				ElecContOperLogEntity entity=entityList.get(i);
				ElecContOperLogBo bo=ElecContOperLogBo.entityToBo(entity);
				boList.add(bo);
			}
		}catch(Exception e){
			BaseLog.e(this.getClass(), "findAllList 查询失败", e);
		throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public List<ElecContOperLogBo> findAllListPage(ElecContOperLogBo param){
		List<ElecContOperLogBo> boList=new ArrayList<ElecContOperLogBo>();
		List<ElecContOperLogEntity> entityList=new ArrayList<ElecContOperLogEntity>();
		try{
		entityList=elecContOperLogMapper.findAllListPage(param);
			for(int i=0;i<entityList.size();i++){
				ElecContOperLogEntity entity=entityList.get(i);
				ElecContOperLogBo bo=ElecContOperLogBo.entityToBo(entity);
				boList.add(bo);
		}
		}catch(Exception e){
			 BaseLog.e(this.getClass(), "findAllList 查询失败", e);
			 throw new BaseException("查询！",e);
		}
		return boList;
}
	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Tue Aug 27 10:30:57 CST 2019
	*/
	public int count(ElecContOperLogBo bo){
		int count=0;
		try{
			    ElecContOperLogEntity entity=ElecContOperLogBo.boToEntity(bo);
			    count=(Integer)elecContOperLogMapper.count(entity);
			}catch(Exception e){
				 BaseLog.e(this.getClass(), "findById 查询失败", e);
				 throw new BaseException("查询！",e);
			}
		return count;
	}

   }

